home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / GRAPHICS / GIF2RPC.SPK / source / c / gif2rpcFE < prev    next >
Text File  |  1996-01-14  |  2KB  |  95 lines

  1. /* gif2rpcFE.c
  2.  * AUTHOR:      Cy Booker, cy@cheepnis.demon.co.uk
  3.  * LICENSE:     FreeWare, Copyright (c) 1995 Cy Booker, but see below
  4.  * PURPOSE:     pretend to be gif2spr
  5.  *              Ie ignore -v and -q flags, and pass rest of command line
  6.  *              onto gif2rpc executable
  7.  *              assumes gif2rpc is in same directory as this executable
  8.  */
  9.  
  10. #include <assert.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14.  
  15.  
  16. /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  17.  */
  18.  
  19. #define GIF2RPC "chain:%sgif2rpc -gif %s -sprite %s"
  20.  
  21. /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  22.  */
  23.  
  24.  
  25. /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  26.  */
  27.  
  28. int main(
  29.                 int             argc,
  30.                 char            **argv) {
  31.   const char    *sprite = NULL;
  32.   const char    *gif = NULL;
  33.   char          *app;
  34.   char          *rove;
  35.   char          *buffer;
  36.   int           idx;
  37.  
  38.   argc = argc;
  39.  
  40.   #ifdef DEBUG
  41.     freopen("$.log", "w+", stdout);
  42.     printf("arg[0] = `%s'\n", argv[0]);
  43.   #endif /* DEBUG */
  44.   app = argv[0];
  45.   assert(app);
  46.   for (idx= 1; (argv[idx]); idx++) {
  47.     #ifdef DEBUG
  48.       printf("arg[%d] = `%s'\n", idx, argv[idx]);
  49.     #endif /* DEBUG */
  50.     if ((strcmp(argv[idx], "-v") != 0)
  51.         && (strcmp(argv[idx], "-q") != 0)) {
  52.       if (gif == NULL) {
  53.         gif = argv[idx];
  54.       } else {
  55.         assert(sprite == NULL);
  56.         sprite = argv[idx];
  57.       }
  58.     }
  59.   }
  60.   #ifdef DEBUG
  61.     printf("gif = `%s'\n", gif);
  62.     printf("sprite = `%s'\n", sprite);
  63.   #endif /* DEBUG */
  64.   assert(gif);
  65.   assert(sprite);
  66.   /*
  67.    * search for end of directory part of path name
  68.    * because we are assuming the gif2rpc executable is in the
  69.    * same directory as (this) gif2rpcFE executable
  70.    */
  71.   rove = strrchr(app, '.');
  72.   if (!rove) {
  73.     /*
  74.      * cope with `path's
  75.      */
  76.     rove = strrchr(app, ':');
  77.   }
  78.   if (rove) {
  79.     rove[1] = '\0';
  80.   } else {
  81.     /*
  82.      * implicit path (csd)
  83.      */
  84.     app[0] = '\0';
  85.   }
  86.   buffer = malloc(strlen(app) + strlen(GIF2RPC) + strlen(gif) + strlen(sprite));
  87.   assert(buffer);
  88.   sprintf(buffer, GIF2RPC, app, gif, sprite);
  89.   #ifdef DEBUG
  90.     printf("launching: `%s'\n", buffer);
  91.   #endif /* DEBUG */
  92.   system(buffer);
  93.   return EXIT_SUCCESS;
  94. }
  95.